package io;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class ReadStringDemo {//读取文本数据
    public static void main(String[] args) throws IOException {
        File file =new File("fos.txt");
        FileInputStream fis =new FileInputStream(file);
        byte[] data=new byte[(int)file.length()];//强制转换
        fis.read(data);
        String line =new String(data, StandardCharsets.UTF_8);//将data中的字节还原为字符串
        System.out.println(line);
        fis.close();

    }
}
